// 53. 最大子数组和
class Solution {
public:
    int maxSubArray(vector<int>& nums) {
        int ret = nums[0];
        int sum = 0;
        for(auto e : nums)
        {
            if(sum > 0) sum += e;
            else sum = e;
            ret = max(ret, sum);
        }
        return ret;
    }
};

// 238. 除自身以外数组的乘积
class Solution {
public:
    vector<int> productExceptSelf(vector<int>& nums) {
        int n = nums.size();
        vector<int> left(n, 1), right(n, 1), ret(n);
        for(int i = 1; i < n; i++) left[i] = left[i-1] * nums[i - 1];
        for(int i = n-2; i >= 0; i--) right[i] = right[i+1] * nums[i+1];
        
        for(int i = 0; i < n; i++) ret[i] = left[i] * right[i];

        return ret;
    }
};